{% macro static(filename) -%}
    {{ url_for('static',filename=filename) }}
{%- endmacro %}

{% macro default_img(img) -%}
    {{ img|default('/static/global/face/default.png',true)}}
{%- endmacro %}

{% macro no_img(img) -%}
    {{ img|default('/static/global/face/no-image.png',true)}}
{%- endmacro %}

{% macro authAction(url,cationType="create",param="") -%}
    {% if url.split('?')[0] in  g.role_pri_path or g.role_type == 1 -%}
    {% if cationType == 'create' %}<a href="{{ url }}" class="btn btn-sm btn-primary"><i class="fa fa-save"></i> 新增</a>{% endif %}
    {% if cationType == 'edit' %}<a href="{{ url }}" class="btn btn-primary btn-xs"><i class="fa fa-edit"></i> 编辑</a>{% endif %}
    {% if cationType == 'delete' %}<a href="javascript:void(0)" data-url="{{ url }}" data-id="{{ param }}"class="btn btn-danger btn-xs delete-one"><i class="fa fa-trash"></i> 删除</a>{% endif %}
    {% if cationType == 'delete_all' %}<a href="javascript:void(0)" data-url="{{ url }}" class="btn btn-sm btn-danger delete-all"><i class="fa fa-trash"></i> 删除</a>{% endif %}
    {% if cationType == 'backup' %}<a class="btn btn-primary btn-sm delete-all" href="javascript:void(0)" data-url="{{ url }}" data-title="备份"><i class="fa fa-save"></i> 备份</a>{% endif %}
    {% if cationType == 'restore'%}<a class="btn btn-primary btn-xs delete-one" href="javascript:void(0)" data-url="{{ url }}" data-id="{{ param }}" data-title="还原"><i class="fa fa-rotate-left"></i> 还原</a>{% endif %}
    {% if cationType == 'dowonload'%}<a class="btn btn-warning btn-xs" href="{{ url }}"><i class="fa fa-download"></i>下载备份文件</a>{% endif %}
    {%- endif %}
{%- endmacro %}


{% macro render_page_data(page_data,page_function) %}
  <div class="box-footer clearfix">
    <ul class="pagination pagination-sm no-margin pull-right">
      <li><a href="{{ url_for(page_function,page = 1) }}">首页</a></li>
      {% if page_data.has_prev %}
        <li><a href="{{ url_for(page_function,page = page_data.prev_num) }}">«</a></li>
      {% endif %}
      {% for page in page_data.iter_pages() %}
        {% if page %}
          {% if page !=page_data.page %}
            <li><a href="{{ url_for(page_function,page = page) }}">{{ page }}</a></li>
          {% else %}
            <li class="active"><a href="#">{{ page }}</a></li>
          {% endif %}
        {% endif %}
      {% endfor %}
      {% if page_data.has_next %}
        <li><a href="{{ url_for(page_function,page = page_data.next_num) }}">»</a></li>
      {% endif %}
      <li><a href="{{ url_for(page_function,page = page_data.pages) }}">末页</a></li>
    </ul>
  </div>
{% endmacro %}

{% macro terms_render_page_data(page_data,page_function,param) %}
  <div class="box-footer clearfix">
    <ul class="pagination pagination-sm no-margin pull-right">
      <li><a href="{{ url_for(page_function,page = 1,taxonomy=param) }}">首页</a></li>
      {% if page_data.has_prev %}
        <li><a href="{{ url_for(page_function,page = page_data.prev_num,taxonomy=param) }}">«</a></li>
      {% endif %}
      {% for page in page_data.iter_pages() %}
        {% if page %}
          {% if page !=page_data.page %}
            <li><a href="{{ url_for(page_function,page = page,taxonomy=param) }}">{{ page }}</a></li>
          {% else %}
            <li class="active"><a href="#">{{ page }}</a></li>
          {% endif %}
        {% endif %}
      {% endfor %}
      {% if page_data.has_next %}
        <li><a href="{{ url_for(page_function,page = page_data.next_num,taxonomy=param) }}">»</a></li>
      {% endif %}
      <li><a href="{{ url_for(page_function,page = page_data.pages,taxonomy=param) }}">末页</a></li>
    </ul>
  </div>
{% endmacro %}
